package org.example.domain.user_raffle.repository;


import org.apache.commons.lang3.tuple.Pair;
import org.example.domain.user_raffle.model.entity.ActivityEntity;
import org.example.domain.user_raffle.model.entity.ActivityStrategyPrizeEntity;
import org.example.domain.user_raffle.model.entity.PrizeEntity;
import org.example.domain.user_raffle.model.entity.StockZeroTaskEntity;

import java.math.BigDecimal;
import java.util.List;
import java.util.Map;

/**
 * @author lxc18
 * @date 2025/3/29 16:36
 * @description IUserRaffleService
 */
public interface IUserRaffleRepo {

    ActivityEntity queryActivityById(Long activityId);


    int queryUserQuota(Long activityId,Long userId);

    int queryUserUsedQuota(Long activityId,Long userId);
    //验证用户额度是否大于0

    //2、验证用户是否在黑名单中：
    boolean isInBlackList(Long activityId,Long userId);

    //查询策略配置
    ActivityStrategyPrizeEntity queryStrategy(Long activityId, String strategyName);

    //查询奖品
    PrizeEntity queryPrizeById(Long prizeId);
    //查询奖品库存（从缓存中）
    int queryPrizeStock(Long prizeId);

    //扣减库存（从缓存中）延迟队列
    Long deductPrizeStock(Long prizeId);



    //用户抽奖记录增加
    boolean addUserRaffleRecord(Long activityId,Long userId,Long prizeId);

    List<Long> getAllPrizeIds();

    void decrPrizeStock(Long prizeId,int size);

    int deductUserQuotaAndAddUsedQuota(Long activityId, Long userId);

    void clearUsedQuota(Long activityId, Long userId,int quota);

    Long postProcess(Long userId, Long activityId, Long result, Long prizeId);


    void updateStatusFailed(Long id);

    void updateStatusSuccess(Long id);

    boolean isTaskStockZero(Long id);

    void updateStockToZero(Long prizeId);

    List<StockZeroTaskEntity> getAllFailedTaskIds();

    boolean isGuaranteePrize(Long activityId, Long prizeId);

    List<Pair<Long, BigDecimal>> queryPrizeByIds(List<Long> prizeIds);

    Map<String, ActivityStrategyPrizeEntity> queryAllStrategy(Long activityId);
}
